/**
 * Author: Brent Myers
 * Time-stamp: <2008-07-23 20:56:28 bam>
 * 
 * Top Level Hashtable Interface
 * 
 * some elements of interface taken from the
 * Standard Template Library Programmer's Guide
 *
 * http://www.sgi.com/tech/stl/hash_map.html
 */
#ifndef _GEN_HASHTABLE_H_
#define _GEN_HASHTABLE_H_

#include <utility>
#include <cstddef>

using std::size_t;
using std::pair;
using std::make_pair;

namespace genhash {

template <class CollisionStrategy_>
class Hashtable
{
public:
	typedef CollisionStrategy_ CollisionStrategy;

	typedef typename CollisionStrategy::key_type key_type;
	typedef typename CollisionStrategy::data_type data_type;
	typedef typename CollisionStrategy::value_type value_type;
	typedef typename CollisionStrategy::hasher hasher;

	typedef typename CollisionStrategy::iterator iterator;

	/**
	 * constructor
	 */
	Hashtable() {}

    /**
	 * destructor
	 */
	~Hashtable() {}


	iterator begin()
	{
		return cs.begin();
	}

	iterator end()
	{
		return cs.end();
	}

	size_t size() const
	{
		return cs.size();
	}

	size_t max_size() const
	{
		return cs.max_size();
	}

	bool empty() const
	{
		return cs.empty();
	}


	/**
	 * insert
	 */
	pair<iterator, bool> insert(const value_type& x) 
	{ 
		return cs.insert(x); 
	}

	/**
	 * insert
	 */
	pair<iterator, bool> insert(const key_type& k, const data_type& d)
	{
		return insert(make_pair(k, d));
	}

	/**
	 * find
	 */	
	iterator find(const key_type& k)
	{
		return cs.find(k);
	}

	/**
	 * []
	 */
	data_type& operator[](const key_type& k)
	{
		return (*((insert(value_type(k, data_type()))).first)).second;
	}

private:
	CollisionStrategy cs;
	
};

}

#endif // _GEN_HASHTABLE_H_

